import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class StudentGradeSystem {
    private Map<String, Integer> studentGrades = new HashMap<>();
    private Scanner scanner = new Scanner(System.in);

    // 记录学生成绩
    public void recordStudentGrade() {
        System.out.println("请输入学生姓名:");
        String name = scanner.nextLine();
        System.out.println("请输入学生成绩:");
        int grade = Integer.parseInt(scanner.nextLine());
        
        studentGrades.put(name, grade);
        System.out.println("成功记录 " + name + " 的成绩: " + grade);
    }

    // 查询学生成绩
    public void queryStudentGrade() {
        System.out.println("请输入要查询的学生姓名:");
        String name = scanner.nextLine();
        
        if (studentGrades.containsKey(name)) {
            System.out.println(name + " 的成绩是: " + studentGrades.get(name));
        } else {
            System.out.println("未找到该学生的成绩记录");
        }
    }

    public static void main(String[] args) {
        StudentGradeSystem system = new StudentGradeSystem();
        Scanner scanner = new Scanner(System.in);
        
        while (true) {
            System.out.println("\n1. 记录学生成绩");
            System.out.println("2. 查询学生成绩");
            System.out.println("3. 退出");
            System.out.print("请选择操作: ");
            
            int choice = Integer.parseInt(scanner.nextLine());
            
            switch (choice) {
                case 1:
                    system.recordStudentGrade();
                    break;
                case 2:
                    system.queryStudentGrade();
                    break;
                case 3:
                    System.exit(0);
                default:
                    System.out.println("无效选择");
            }
        }
    }
}